########################################################## ## ## ## Real and Simulated Spatial PP.r ## ## ## ## Jonathan Reuning-Scherer, Yale University ## ## FES 781 Applied Spatial Statistics ## ## Revised Feb 2014 ## ## ## ########################################################## #Graphs showing differece between CSR and separation #make four plots per page par(mfrow=c(2,2)) #complete randomness x<-runif(50,0,10) y<-runif(50,0,10) plot(x,y, pch=19,col='red',cex=1.2,main="CSR",xlab='x',ylab='y') #separation spatially x<-runif(50,0,1)+rep(c(1:10),5) y<-runif(50,0,1)+c(t(matrix(rep(c(1:10),5),ncol=5))) plot(x,y, pch=19,col='red',cex=1.2,main="Systematic Process",xlab='x',ylab='y') #10 Clustered process xa<-runif(50) ya<-runif(50) movex<-runif(10,1,10) movex<-sort(rep(movex,5))+xa movey<-runif(10,1,10) movey<-rep(movey,each=5)+ya plot(movex,movey,pch=19,cex=1.2,col='red', main="Clustered Process",xlab='x',ylab='y') #10 Regular Clusters xsmile<-rep(c(1.5,3,5,7,8.5,5,2.5,7.5),6)+runif(48) ysmile<-rep(c(3,1.5,1,1.5,3,5,8,8),6)+runif(48) plot(xsmile,ysmile,pch=19,cex=1.2,col='red', main="Regular Clustered Process",xlab='x',ylab='y', xlim=c(1,10),ylim=c(1,10)) #another way to do generate a CSR using the spatstat package library(spatstat) #make one plot per page par(mfrow=c(1,1)) #generate a CSR over the range (0,10) x (0,10) with mean 1 per unit square pois1<-rpoispp(1,win=owin(xrange=c(0,10),yrange=c(0,10))) plot(pois1$x,pois1$y, main="CSR process Using SPATSTAT", col="red", xlab="", ylab="")